package com.yueya.basic.role.model;

import java.util.List;

import com.jfinal.aop.Duang;
import com.jfinal.plugin.activerecord.Model;
import com.yueya.basic.role.service.RoleService;

/**
 * Role model.
 */
@SuppressWarnings("serial")
public class Role extends Model<Role> {
	public static final Role dao = new Role();

	public static RoleService service = Duang.duang(RoleService.class);

	public List<Role> getAllRole() {
		String sql = "select * from t_role where status = '1' and del_flag = '0' order by level asc";
		return dao.find(sql);
	}

	public Role findByUserId(String userId) {
		String sql = "select r.* from t_role_user ru inner join t_role r on ru.role_id = r.id where ru.user_id = ?";
		return Role.dao.findFirst(sql , userId);
		
	}

}